﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Financeiro.Dados;
using System.Security.Cryptography;
using System.Data;


namespace Financeiro.Model
{
    public class LoginModel
    {
        static public bool autenticar(string login, string password)
        {
            return LoginDAO.autenticar(login, password);
        }
         
        static public bool registrar(string login, string password, string nome)
        {
            // criptografando a senha
            HashAlgorithm mhash = new SHA1CryptoServiceProvider();
            byte[] bytValue = System.Text.Encoding.UTF8.GetBytes(password);
            byte[] bytHash = mhash.ComputeHash(bytValue);
            mhash.Clear();

            string cryptPassword = Convert.ToBase64String(bytHash);

            return LoginDAO.registar(login, cryptPassword, nome);

        }

        static public DataTable buscarLogins()
        {
            return LoginDAO.buscarLogins();
        }

        static public void apagaLogin(int id)
        {
            LoginDAO.apagaLogin(id);
        }

    }
}
